#include "microfor.h"
#include <QFile>




TData CMicroforSource::readData()
{
    QString path = parameter.toString();
    if (!QFile::exists(path)) return TData();
    QFile file(path);
    if (!file.open(QIODevice::ReadOnly)) return TData();
    int size = sizeof(TData);
    file.seek(file.size() - size);
    QByteArray bytes = file.read(size);

    file.close();
    TData * data = (TData*)bytes.data();
    TData dat = *data;

    if (dat.temperature > 300 || dat.temperature < -70) return TData();
    if (dat.humidity > 100 || dat.humidity < 0) return TData();
    return dat;
}
